package bitmap
{
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.system.ApplicationDomain;
	import flash.utils.Dictionary;
	import flash.utils.describeType;
	import flash.utils.getDefinitionByName;

	public class BitmapLibrary
	{
		private var _bitmapMovieClips:Dictionary;
		
		public function BitmapLibrary()
		{
			_bitmapMovieClips=new Dictionary();
		}
		
		private static var _instance:BitmapLibrary;
		public static function get Instance():BitmapLibrary
		{
			if(_instance == null)
			{
				_instance = new BitmapLibrary();
			}
			return _instance;
		}
		
		public function creatClip(classPath:String):BitmapMovieClip
		{
			if(_bitmapMovieClips[classPath]==null)
			{
				var obj:Object=getDefinitionByName(classPath);
				var bitmapAnimation:BitmapAnimation = new BitmapAnimation(new obj(), BitmapFrameObjectType.MOVIE_CLIP);
				_bitmapMovieClips[classPath]=bitmapAnimation;
			}
			
			return new BitmapMovieClip(_bitmapMovieClips[classPath] as BitmapAnimation);
		}
	}
}